﻿using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using Esponce.Common;

namespace Esponce.QRCode
{
	[DataContract(Name = "event", Namespace = "")]
	public class ScheduleEventModel : INotifyPropertyChanged
	{
		#region Public properties
		[DataMember(Name = "content", IsRequired = false, EmitDefaultValue = false, Order = 1)]
		public string Content
		{
			get
			{
				return this.content;
			}
			set
			{
				if (this.content != value)
				{
					this.content = value;
					OnPropertyChanged("Content");
				}
			}
		}
		private string content;

		[DataMember(Name = "recurrence", IsRequired = false, EmitDefaultValue = false, Order = 2)]
		public Recurrence Recurrence
		{
			get
			{
				return this.recurrence;
			}
			set
			{
				if (this.recurrence != value)
				{
					this.recurrence = value;
					OnPropertyChanged("Recurrence");
				}
			}
		}
		private Recurrence recurrence;

		[DataMember(Name = "date", IsRequired = false, EmitDefaultValue = false, Order = 3)]
		public string DateISO8601
		{
			get
			{
				return ISO8601.GetString(this.Date);
			}
			set
			{
				this.Date = ISO8601.GetDateTime(value);
			}
		}

		public DateTime? Date
		{
			get
			{
				return this.date;
			}
			set
			{
				if (this.date != value)
				{
					this.date = value;
					OnPropertyChanged("Date");
				}
			}
		}
		private DateTime? date;
		#endregion

		#region INotifyPropertyChanged Members
		public event PropertyChangedEventHandler PropertyChanged;
		protected virtual void OnPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		#endregion
	}
}
